You are here

Delete strings in xml file

6 posts / 0 new
Last post
Tapiocapioca
Offline
Has donated long time ago
Joined: 8 years
Last seen: 5 years
Delete strings in xml file

I am trying to make my xml file compatible with android applications, I discovered many applications are not happy about the tag <url>

Is there one way to remove it?

Just for exmple, my actually file is:

<?xml version="1.0" encoding="UTF-8"?>
<tv generator-info-name="WebGrab+Plus/w MDB &amp; REX Postprocess -- version V1.56.24 -- Jan van Straaten" generator-info-url="http://www.webgrabplus.com">
  <channel id="Rai Uno">
    <display-name lang="it">Rai Uno</display-name>
    <icon src="http://www.mywebsite.com/logos/Rai Uno.png" />
    <url>http://www.guidatv.sky.it</url>
  </channel>

I like to have

<?xml version="1.0" encoding="UTF-8"?>
<tv generator-info-name="WebGrab+Plus/w MDB &amp; REX Postprocess -- version V1.56.24 -- Jan van Straaten" generator-info-url="http://www.webgrabplus.com">
  <channel id="Rai Uno">
    <display-name lang="it">Rai Uno</display-name>
    <icon src="http://www.mywebsite.com/logos/Rai Uno.png" />
  </channel>

Tapiocapioca
Offline
Has donated long time ago
Joined: 8 years
Last seen: 5 years
Blackbear199 wrote:

usually we would use rex to remove elements but the url one is different as its kinda auto generated.

you can try rex though,the way to remove a element is to leave it blank..so..

<url></url>

if you have never used rex read under the documentation but basically add a folder in the same directory as you webgrab++.config.xml named rex.inside put the rex.config.xml.edit it and set your filename(its well documented).at the bottom is where the above <url></url> would go.

to enable rex(we call it a post processor) you do it in you webgrab++.config.xml

<postprocess grab="y" run="y">rex</postprocess>

grab is for your normal epg grabbing from websites and run is for the post processor.

if that dont work you can always use good old sed(google it).you can use it in windows or linux.

google on how to either run it from the cmd prompt or create a simple batch file(windows) or shell script(linux).its a 1 liner command.

 

sed  -i "/<url/d" guide.xml

 

Really thank you, i study about now.

Tapiocapioca
Offline
Has donated long time ago
Joined: 8 years
Last seen: 5 years

I did what you told me about rex and works really fine, but I can't use sed command with windows, can you give me some suggestions more? Maybe is there one way to add this command like ssh under windows 7?

Tapiocapioca
Offline
Has donated long time ago
Joined: 8 years
Last seen: 5 years
Blackbear199 wrote:

to use sed for windows you have to download the sed.exe(google it).it doesnt come preinstalled.

then i would put it in same directory as you guide.xml

then create a new file in that same directory named whatever_you_want.bat

sed.bat for example

right click and edit

copy the sed commamd i gave you,think for windows you you need full file name so

sed.exe -i "<url/d" guide.xml

save it

double click the .bat file to run it

you see bunch of stuff scrolling,when it done check if the <url lines are removed.

if its ok edit your bat file again and add this as the first file.

@ECHO OFF 

this will diable the output.

you can incorporate you webgrab execution into the .bat file also,this will run webgrab and then remove all the <url tags.

using default paths,edit guid.xml name to you filename.

.bat filename webgrab.bat

REM -----Run Webrab and then remove the <url tags ------------

@ECHO OFF 
cd C:\ProgramData\ServerCare\WebGrab

WebGrab+Plus.exe

sed.exe -i "<url/d" guide.xml

I did! Really thank you about your help! :D :D :D After i will open a new thread asking help about a different question!

ediri
Offline
Joined: 8 years
Last seen: 5 years

do i need to use GnuWin sed?

Tapiocapioca
Offline
Has donated long time ago
Joined: 8 years
Last seen: 5 years

The better solution I found under Windows is cygwin, you can use all Linux commands, the problem is the file xml many times result corrupted. But if you search there are specific validators about xmltv under linux, you can find it easy. I was crazy because the file was perfect checking watching with notepad++, but rejected from all softwares. After the validator fix it, look like the same but works he he

Log in or register to post comments

Brought to you by Jan van Straaten

Program Development - Jan van Straaten ------- Web design - Francis De Paemeleere
Supported by: servercare.nl