1

I have this xml data format. I would like to extract the properties name and value from it. I have tried to get node by node but it is troublesome.

<?xml version="1.0"> encoding="ASCII"?> 
<xDiagram>  
  <children iD="1261435145010.0" location="Point(547,184)" 
    size="Dimension(102,140)" shapeType="TestInfoShape"
    modelEntityID="TestInfo.7">
    <properties>
      <properties name="desc" type="MultiLinesText"
        parent="this_comp1" parentName="multiLinesText"
        modelPropName="desc" value="create test user can access"/>
      <properties name="name" type="String" parent="this_comp2"
        parentName="text" modelPropName="name" value="testCase1"/>
    </properties>
  </children>
</xDiagram>

Can anyone suggest a better way to do it? I like to use XPath but it can't lock on the element.

Thanks

2
  • did some editing, hardly enough, but data is shown now. Commented Dec 28, 2009 at 4:12
  • This XML is invalid. Copy'n'paste bug? Or also in real? Commented Dec 28, 2009 at 4:31

3 Answers 3

3

XPath is the right tool for this type of job. You can try improving your XPath expression at a site like:

http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm

For example, this XPath will return a NodeList containing all of the inner "Properties" elements:

/xDiagram/children/properties/properties
Sign up to request clarification or add additional context in comments.

Comments

0

The Java Streaming API for XML is also handy (when SAX, DOM, or XPath aren't quite right for the job).

Comments

0

See if JAXB helps you: http://www.roseindia.net/jaxb/r/jaxb.shtml

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.