Tag Archives: c++

Forwarding apache request to a c++ program

Questions: I am basically looking for tips and tricks on how to approach that problem. I have a Server Software (Linux), which is written in C++. What I need to do is to provide some information, that is generated inside that software, via a http call to the apache webserver. Of course it would be… Read More »

C# : Getting all nodes of XML doc

Questions: Is there a simple way, to get all nodes from an xml document? I need every single node, childnode and so on, to check if they have certain attributes. Or will I have to crawl through the document, asking for childnodes? Answers: In LINQ to XML it’s extremely easy: XDocument doc = XDocument.Load(“test.xml”); //… Read More »

Is it possible to ignore namespaces in c# when using xPath?

Questions: I could be given either of the following xml: <?xml version=”1.0″ encoding=”UTF-8″?> <dc:video xmlns:dc=”http://purl.org/dc/elements/1.1/”> <dc:title> A vid with Pete </dc:title> <dc:description> Petes vid </dc:description> <dc:contributor> Pete </dc:contributor> <dc:subject> Cat 2 </dc:subject> </dc:video> Or: <?xml version=”1.0″ encoding=”UTF-8″?> <video> <title> A vid with Pete <title> <description> Petes vid <description> <contributor> Pete <contributor> <subject> Cat 2 <subject>… Read More »

C# – get attribute values from matching XML nodes using XPath query

Questions: This doesn’t seem like it should be difficult, but I’m stuck currently. I’m trying to get the attribute values for a particular attribute from nodes that match a given XPath query string. Here’s what I have so far: public static IEnumerable<string> GetAttributes(this XmlDocument xml, string xpathQuery, string attributeName) { var doc = new XPathDocument(new… Read More »

Decode CDATA section in C#

Questions: I have a bit of XML as follows: <section> <description> <![CDATA[ This is a “description” that I have formatted ]]> </description> </section> I’m accessing it using curXmlNode.SelectSingleNode(“description”).InnerText but the value returns \r\n This is a “description”\r\n that I have formatted instead of This is a “description” that I have formatted. Is there a simple… Read More »

Reading XML comments in C#

Questions: I have got some XML files that contain comments above the nodes. When I am reading the file in, as part of the process I would like to get the comment out as well. I know you can write a comment to the file using XmlComment, but not sure how to read them back… Read More »