STARoDev
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2013
11:52 PM
Help with Parsing XML
Hello,
I am new to the forum and am not sure whether the issue I have is related to my XML or to the brightscript XML parsing routine, so I was hoping someone might point me in the right direction.
The code I am using is:
The result of running this code is that it always prints the error message in the brightscript debugger.
conn.UrlCategoryFeed is an associative array element, which I believe is also a string (am I misunderstanding this?). The XML in the element/string that I am attempting to parse is (validated by "print conn.UrlCategoryFeed" returning this same string):
Can anyone please help me understand why the XML parse is failing? I tried to validate the XML through various web tools, and they all indicate that it is valid. Would the special characters in the XML (e.g., & = & and ') be causing any issues. Any insight would be greatly appreciated!
Thank you!
I am new to the forum and am not sure whether the issue I have is related to my XML or to the brightscript XML parsing routine, so I was hoping someone might point me in the right direction.
The code I am using is:
conn = CreateObject("roAssociativeArray")
conn.UrlCategoryFeed = sXMLREsp ' see XML text in post below
xml=CreateObject("roXmlElement")
if not xml.Parse(conn.UrlCategoryFeed) then
print "Can't parse feed - error loan_category_feed 128"
return invalid
endif
The result of running this code is that it always prints the error message in the brightscript debugger.
conn.UrlCategoryFeed is an associative array element, which I believe is also a string (am I misunderstanding this?). The XML in the element/string that I am attempting to parse is (validated by "print conn.UrlCategoryFeed" returning this same string):
<?xml version="1.0" encoding="utf-16"?><TestResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Success>true</Success><ErrorText>OK</ErrorText><BaseDirectory>G:\Video</BaseDirectory><Directories /><Files><FoundItem><IsDirectory>false</IsDirectory><Name>Air Mater (Pixar Short).jpeg</Name><Size>11230</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Air Mater (Pixar Short).mp4</Name><Size>90090791</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Boundin' (Pixar Short).jpeg</Name><Size>9293</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Boundin' (Pixar Short).mp4</Name><Size>84214597</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Burn-E (Pixar Short).jpeg</Name><Size>6394</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Burn-E (Pixar Short).mp4</Name><Size>86745997</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Day & Night (Pixar Short).jpeg</Name><Size>7344</Size><Duration>0</Duration><Items>0</Items></FoundItem><FoundItem><IsDirectory>false</IsDirectory><Name>Day & Night (Pixar Short).mp4</Name><Size>72547816</Size><Duration>0</Duration><Items>0</Items></FoundItem></Files></TestResult>
Can anyone please help me understand why the XML parse is failing? I tried to validate the XML through various web tools, and they all indicate that it is valid. Would the special characters in the XML (e.g., & = & and ') be causing any issues. Any insight would be greatly appreciated!
Thank you!
2 REPLIES 2
destruk
Streaming Star
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2013
02:57 AM
Re: Help with Parsing XML
XML is easier to read if it's formatted as XML rather than just copying what displays on the screen. As to why it fails, try removing the schema links? Or try UTF-8 instead of UTF-16? Maybe someone else has better ideas.
Your & is correct already, and the standard ' apostrophe shouldn't cause issues for basic parsing.
Your & is correct already, and the standard ' apostrophe shouldn't cause issues for basic parsing.
<?xml version="1.0" encoding="utf-16"?>
<TestResult xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Success>true</Success>
<ErrorText>OK</ErrorText>
<BaseDirectory>G:\Video</BaseDirectory>
<Directories />
<Files>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Air Mater (Pixar Short).jpeg</Name>
<Size>11230</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Air Mater (Pixar Short).mp4</Name>
<Size>90090791</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Boundin' (Pixar Short).jpeg</Name>
<Size>9293</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Boundin' (Pixar Short).mp4</Name>
<Size>84214597</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Burn-E (Pixar Short).jpeg</Name>
<Size>6394</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Burn-E (Pixar Short).mp4</Name>
<Size>86745997</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Day & Night (Pixar Short).jpeg</Name>
<Size>7344</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
<FoundItem>
<IsDirectory>false</IsDirectory>
<Name>Day & Night (Pixar Short).mp4</Name>
<Size>72547816</Size>
<Duration>0</Duration>
<Items>0</Items>
</FoundItem>
</Files>
</TestResult>
STARoDev
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2013
03:29 PM
Re: Help with Parsing XML
Using utf-8 fixed it! Thank you!