xml-parsing

Loading not-so-well-formed XML into XDocument (multiple DTD)

I have got a problem handling data which is almost well-formed XHTML document except for it has multiple DTD declarations in the beginning: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <!DOCTYPE HTML PUBLIC "-//W3C...

Method interception in PHP 5.*

Hi everybody, I'm implementing a Log system for PHP, and I'm a bit stuck. All the configuration is defined in an XML file, that declares every method to be logged. XML is well parsed and converted into a multidimensionnal array (classname => array of methods). So far, so good. Let's take a simple example: #A.php class A { publ...

is there a GetElementByTagName that handles if the tag isn't there

i have the following code below but sometime the "serving_description" tag isn't there. Right now i just put a try catch around it but i wanted to find out if there was a cleaner way to handle this scenario. XmlElement servingElement = (XmlElement)servingNode; serving.Id = Convert.ToInt32(servingElement.GetElementsByTagName("serving_id...

Parsing an XML string containing "&#x20;" (which must be preserved)

I have code that is passed a string containing XML. This XML may contain one or more instances of &#x20; (an entity reference for the blank space character). I have a requirement that these references should not be resolved (i.e. they should not be replaced with an actual space character). Is there any way for me to achieve this? Basic...

Nokogiri pull parser (Nokogiri::XML::Reader) issue with self closing tag

I have a huge XML(>400MB) containing products. Using a DOM parser is therefore excluded, so i tried to parse and process it using a pull parser. Below is a snippet from the each_product(&block) method where i iterate over the product list. Basically, using a stack, i transform each <product> ... </product> node into a hash and process ...

How can I check the content of the arrays? Parsing XML file with ObjectiveC

I have 3 classes-> video { nameVideo, id, description, user... } topic {nameTopic, topicID, NSMutableArray videos; } category {nameCategory, categoryID, NSMUtableArray topics} And then in my app delegate I defined-> NSMutableArray categories; I parse an XML file with this code. I try the arrays hierachy, and i think that i d...

Parse XML and populate in List Box

I've posted the same question here and I've also got couple of good answers as well. While I was trying the same answers, I was getting compilation errors. Later I got to know that we are using .NET 2.0 and our existing application has no references to LINQ files. After searching in SO, i tried to figured out partly: public partial cla...

Best way to replace XML Text

Hi, I have a web service which returns the following XML: <Validacion> <Es_Valido>NK7+22XrSgJout+ZeCq5IA==</Es_Valido> </Validacion> <Estatus> <Estatus>dqrQ7VtQmNFXmXmWlZTL7A==</Estatus> </Estatus> <Generales> <Nombre>V4wb2/tq9tEHW80tFkS3knO8i4yTpJzh7Jqi9MxpVVE=</Nombre> <Apellido>jXyRpjDQvsnzZz+wsq6b42am...

RDF/XML format to JSON

I am trying to convert the RDF/XML format to JSON format. Is there any python (library) example that i can look into for this to do ? ...

parsed xml file: skip creation if blank?

This could be a HappyMapper specific question, but I don't think so. In my app, users can upload their blog subscriptions (via an OPML file), which I parse and add to their profile. The only problem is during the parsing, or more specifically the creation of each subscription, I can't figure out how to skip over entries that are just ...

Remove anchor from URL in C#

I'm trying to pull in an src value from an XML document, and in one that I'm testing it with, the src is: <content src="content/Orwell - 1984 - 0451524934_split_2.html#calibre_chapter_2"/> That creates a problem when trying to open the file. I'm not sure what that #(stuff) suffix is called, so I had no luck searching for an answer. I'd...

jquery selector logical AND?

In jQuery I'm trying to select only mount nodes where a and b's text values are 64 and "test" accordingly. I'd also like to fallback to 32 if no 64 and "test" exist. What I'm seeing with the code below though, is that the 32 mount is being returned instead of the 64. The XML: <thingses> <thing> <a>32</a> <-- note, a here i...

How to read from an XmlReader without moving it forwards

hey guys, I've got this scenario: while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element && reader.Name == itemElementName) { XElement item = null; try { item = XElement.ReadFrom(reader) as XElement; } catch (XmlException ex) { //log line number a...

XML Parsing need help iphone sdk

Hi all, How do you get "MayurS123" from following xml tag by parsing? <eletitle lnk="http://192.168.10.2/justmeans/trunk/newsfeed/mayurs"&gt;MayurS123 Sharma</eletitle> My file is getting parsed properly. Here I'm able to retrieve the lnk component by doing: if([elementName isEqualToString:@"eletitle"]) { aGoodwork.lnk = [at...

How to parse multi record XML file ues XML::Simple in Perl

Hello. My data.xml <?xml version="1.0" encoding="ISO-8859-1"?> <catalog> <cd country="UK"> <title>Hide your heart</title> <artist>Bonnie Tyler</artist> <price>10.0</price> </cd> <cd country="CHN"> <title>Greatest Hits</title> <artist>Dolly Parton</artist> <price>9.99</price> </cd> <cd country="USA"> ...

Element Based XML Parsing

I have an XML document which reads like this: <xml> <web:Web> <web:Total>4000</web:Total> <web:Offset>0</web:Offset> </web:Web> </xml> my question is how do I access them using a library like BeautifulSoup in python? xmlDom.web["Web"].Total ? does not work? ...

How to get data for BeautifulSoup Xml Parser

Hi, I'm trying to parse an XML file with BeautifulSoup. In all tutorials on the net, the content of the xml is given like xml = "<doc><tag1>Contents 1<tag2>Contents 2<tag1>Contents 3" soup = BeautifulStoneSoup(xml) but I want to give only xml file's path. In mechanize one can use get_data() method but it only works for html files. A...

Simple XML parser in bison/flex

I would like to create simple xml parser using bison/flex. I don't need validation, comments, arguments, only <tag>value</tag>, where value can be number, string or other <tag>value</tag>. So for example: <div> <mul> <num>20</num> <add> <num>1</num> <num>5</num> </add> </mul> <id>test</id> </div> If it h...

Difference between Dom parser and Xerces Parser

Hey, can anyone please tell me, what are difference between "Dom parser" and "Xerces Parser". What are the advantage and Disadvantages of either. ...

Error handling for xml parsing

I'm using tinyxml to parse xml files, and I've found that error handling here lends itself to arrow code. Our error handling is simply reporting a message to a file. Here is an example: const TiXmlElement *objectType = dataRoot->FirstChildElement( "game_object" ); if ( objectType ) { do { const char *path = objectType->At...