XML library

agraham

Expert
Licensed User
Longtime User
Version 2.6 posted. XmlNode now has a Clone method that returns a deep or shallow clone of itself.

I'll just mention the IDE-hints ...
There's no point mentioning them as I have no control over them. Unfortunately my convention for in or out is opposite to the IDE. My which is Input to the application is equivalent to its' [O] which is Output from the library. I think the IDE convention may be a Microsoft one whereas mine is common-sense :).
 

mjcoon

Well-Known Member
Licensed User
Version 2.6 posted. XmlNode now has a Clone method that returns a deep or shallow clone of itself.

Thank you yet again Andrew. I sorted out what I was doing wrong with my .xml -> .xml copying mechanism, but have now converted to the new Clone method and it works a treat.

Regards, Mike.
 

TWELVE

Active Member
Licensed User
Hello, agraham. In my prog i need to send a XML string to server and then get a response (XML too). Can it be done with this lib? Not to save into file, just get the xml string to send it and then not to open a file, just parse the response string.

I'm afraid that this library only reads from, and writes to, files.

In a nutshell - No!

Is this still the case..? That's too bad, i need this feature as well.Since most B4P Libs appear to me just as a .NET wrapper, my question would be then: is this feature contained in a newer .NET CF version ( 3.5 ?)..?

For a string from a protocol conversation i might be done using B4P string operations but if it grows and get more complex over time the code might become bulky and too complicated.

Maybe an existing piece of...code in C could be converted to a B4P Lib...


regards,

TWELVE
 

agraham

Expert
Licensed User
Longtime User
Maybe an existing piece of...code in C could be converted to a B4P Lib...
Nope! C as an unmanaged language has nothing to do with .NET and any existing .NET code would have nothing to do with what you want.

XMLReader and XMLWriter read/write .NET Streams. The library uses FileStreams. The way to do what you want would be to make MemoryStreams from which to read/write string data as a series of bytes and pass those streams to the library. It is not terribly difficult but I would not do it just for this one library but would make it more generic in a library like FilesEx and then just expose a Stream interface in the libraries that could make use of it. But I'm not likely to do that very soon.

Anyway as you are accessing a server, presumably over a network, I would have thought the overhead of using temporary files would be pretty small.
 

corwin42

Expert
Licensed User
Longtime User
Is this still the case..? That's too bad, i need this feature as well.Since most B4P Libs appear to me just as a .NET wrapper, my question would be then: is this feature contained in a newer .NET CF version ( 3.5 ?)..?

I haven't tried it but I think you can use the XMLDocument object for this. With XMLDocument.LoadXml(xxx) you can load an XML document from a String and with the XMLDocument.xml property you should have access to the xml text of the XMLDocument object.
 

mjcoon

Well-Known Member
Licensed User
I haven't tried it but I think you can use the XMLDocument object for this. With XMLDocument.LoadXml(xxx) you can load an XML document from a String and with the XMLDocument.xml property you should have access to the xml text of the XMLDocument object.

I haven't tried it either (though I am using XML.dll to do KML), and LoadXML may work, but unfortunately the XML: property is described as:

Xml : String [I/O] : Gets or sets the markup representing the children of the current node.

This suggests that the string you get does not include the document object itself. Thus a bit of massaging may be required.

Mike.
 

agraham

Expert
Licensed User
Longtime User
Here's a more comprehensive description of the XML property, which is actually the InnerXml property of the underlying .NET XmlDocument object.
XmlDocument.InnerXml Property (System.Xml)

The line in the help "Gets or sets the markup representing the children of the current node" which I dutifully copied to the help actually appears to be wrong in this instance and seems to be copied from the XmlNode.InnerXml property help where it is correct.
 

mjcoon

Well-Known Member
Licensed User
I'm exploring parts of syntax of KML and GPX where elements are optional.

Until now there have been several candidates that I wanted to process, so I have worked my way through a XMLNodeList of children. But now I want to process a <name> child node if present but no other children.

So it seems overkill to build a XMLNodeList when I can just get the one I want by GetChild2("name"). But the problem I have is knowing if such a node was found.

(The same would apply if looking for an attribute; it just so happens that the ones I want are all mandatory.)

Short of using exception handling, how to determine if a node is present?

Mike.
 

mjcoon

Well-Known Member
Licensed User
A new problem with LoadXmlFile(). I have a KML file that is 2.1Mb which fails to load on PPC whereas it is OK on PC.

So I guess this is a memory problem.

Am I right that there is not going to be a solution to this problem?

Mike.
 

mjcoon

Well-Known Member
Licensed User
Can you use an XmlReader instead, that won't suffer the same expansion problem?

Thanks for the confirmation Andrew. Using XmlReader would be hard work because the crucial data gets decanted into arrays (hence my recent question about how to park a 2-D array in a file). So I need to know the size of the array first which would require two passes through the file. Unless I change to using collections, which I suppose would be slower in action...

Mike.
 

mjcoon

Well-Known Member
Licensed User
I cannot get to grip with prefixes and namespaces.

How do I use this XMLWriter of library XML to get this sort of heading?
<Files xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Mike.
 

PdaMoc

Member
Licensed User
Hy agraham!

I have a html document where I would like to use your library to get the content of an element.
I have just class name. How can I get the content of the structure about the class name?

B4X:
<div class="details-catbar"><span class="catbar-text"><h3>ESTO Fortuna 60305-2 falilámpa</h3></span></div>
<div class="product-image-first"><a href="http://www.bavill.hu/components/com_virtuemart/shop_image/product/ESTO_falil__mpa_5056fbac54c4f.jpg" title="ESTO Fortuna 60305-2 falilámpa" rel="rokbox[250 415](product3622)"><img src="http://www.bavill.hu/components/com_virtuemart/shop_image/product/ESTO_falil__mpa_5056fbac54aa3.jpg" alt="ESTO Fortuna 60305-2 falilámpa" border="0" width="300"></a></div>
<div class="home-featured-sku">Cikkszám: 60305-2</div>
<span class="productPrice">16 470 Ft        (27 % áfával)    </span>
<div class="product-description">
    <p>2 db LED égős fali lámpa. Hossza 170 mm. A lámpa burák átmérője 800 mm. Égők: 5 x 42 W. Foglalat: G9. Anyaga: króm és üveg.</p>
</div>
 

agraham

Expert
Licensed User
Longtime User
Firstly it needs well-formed XML and not HTML.

Secondly, as I stated in the first post
There is a (sort of - I don't really understand XML) demo, help and source for merging in the archive. If anyone who understands XML needs more functionality then post here and I will try to add it.
 
Top